<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

    属性描述符

    <script>
        /**
         * configurable: false  是否可配置
         * enumerable: true 是否可以遍历(for in)
         * value: 1 
         * writable: true 是否可以修改
         * */
        // var a = 1
        // console.log(Object.getOwnPropertyDescriptor(window, 'a'));


        // 2.定义属性 默认值都是false
        var obj = {
            a: 1
        }
        Object.defineProperty(obj, 'b', {
            configurable: false,
            enumerable: false,
            value: 10,
            writable: false
        })

        // 2.2定义多个属性
        Object.defineProperties(obj, {
            c: {
                value: 30
            },
            d: {
                value: 20
            }
        })
        console.log(obj);

        // 手写bind
        function myBind() {
            let context = this
            let args = Array.prototype.slice.call(arguments)
            let that = args.shift()

            return function() {
                let arr = Array.prototype.slice.call(arguments)
                context.apply(that, args.concat(arr))
            }
        }
    </script>
</body>

</html>